from flask import Flask
from app.config import Config


def create_app(config_class=Config):
    # 创建Flask对象
    app = Flask(__name__)

    # 为app加载配置
    app.config.from_object(config_class)

    # 注册蓝图
    from app.routes.main import main_bp
    from app.routes.training import training_bp
    from app.routes.inference import inference_bp
    from app.routes.data import data_bp

    app.register_blueprint(main_bp)
    app.register_blueprint(training_bp)
    app.register_blueprint(inference_bp)
    app.register_blueprint(data_bp)

    return app
